Camera Utils
The CameraUtils class in the @promaton/scan-viewer library provides a set of utilities to control cameras across all views simultaneously. This class is essential for managing camera animations and resetting views to their default positions.
Overview
The CameraUtils class is designed to simplify camera control in multi-view environments. It allows developers to animate cameras to specific targets and recenter all views with ease.
Extended By
- Computed
Constructors
new CameraUtils()
Creates a new instance of the CameraUtils class.
Returns
- CameraUtils: A new instance of the
CameraUtilsclass.
Methods
animateCameras(target)
Animates all cameras to a specified target.
Parameters
- target: A
CameraAnimationTargetobject that defines the target position and orientation for the cameras.
Returns
- void
recenterAllViews()
Recenters all views to their default positions based on the current selection and the scene center.
Returns
- void
Usage Example
import { CameraUtils } from "@promaton/scan-viewer";
// Create an instance of CameraUtils
const cameraUtils = new CameraUtils();
// Animate cameras to a specific target
const target = {
position: { x: 10, y: 20, z: 30 },
lookAt: { x: 0, y: 0, z: 0 },
};
CameraUtils.animateCameras(target);
// Recenter all views to their default positions
CameraUtils.recenterAllViews();
Summary
The CameraUtils class is a powerful tool for managing camera behavior in multi-view applications. With its methods, you can easily animate cameras to specific targets or reset views to their default state, enhancing the user experience in 3D environments.